package com.dslcode.cloud.common.model.order;

import com.dslcode.cloud.common.enums.order.OrderState;
import com.dslcode.cloud.common.model.BaseModel;
import com.dslcode.cloud.common.utils.StringUtil;
import lombok.Data;

import java.math.BigDecimal;

/**
 * Created by dongsilin on 2017/9/21.
 */
@Data
public class Order extends BaseModel {

    private String sn; // 订单编号
    private String paySn; // 支付编号
    private String payTradeSn;//支付公司返回的支付流水号
    private Long buyerId;
    private String buyerName; // 买家姓名
    private long addTime; // 订单生成时间
    private String paymentCode; // 支付方式名称代码
    private long paymentTime; // 支付(付款)时间
    private long finishedTime ; // 订单完成时间
    private BigDecimal goodsAmount; // 商品总价格
    private BigDecimal orderAmount; // 订单总价格
    private BigDecimal shippingFee; // 运费
    private int evaluationState; // 评价状态 0未评价，1已评价，2已过期未评价

    private OrderState orderState; // 订单状态：0(已取消)10(默认):未付款;20:已付款;30:已发货;40:已收货;

    private int refundState;// 退款状态 1为退款,2为退货 3为换货 4为同意退款 5为同意退货，等待用户退货 6为同意换货，等待用户退货 7为退款失败 8为退货失败 9为换货失败 10 退款,用户已发货 11 退货,用户已发货 12 换货,用户已发货 13为退款完成 14为退货完成 15为换货完成
    private int lockState; // 锁定状态:0是正常,大于0是锁定,默认是0
    private int deleteState; // 删除状态0未删除1放入回收站2彻底删除
    private String shippingCode; // 物流单号
    public Order() {
    }

    public Order(String paySn, Long buyerId, String buyerName, BigDecimal goodsAmount, BigDecimal orderAmount, BigDecimal shippingFee) {
        this.sn = StringUtil.append2String(System.currentTimeMillis(), buyerId);
        this.paySn = paySn;
        this.payTradeSn = "";
        this.buyerId = buyerId;
        this.buyerName = buyerName;
        this.addTime = System.currentTimeMillis() / 1000;
        this.paymentCode = "";
        this.paymentTime = 0;
        this.finishedTime = 0;
        this.goodsAmount = goodsAmount;
        this.orderAmount = orderAmount;
        this.shippingFee = shippingFee;
        this.evaluationState = 0;
        this.orderState = OrderState.not_pay;
        this.refundState = 0;
        this.lockState = 0;
        this.deleteState = 0;
        this.shippingCode = "";
    }

}
